package com.lzm.ydpt.module.mall.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.byt.framlib.base.BaseActivity;
import com.byt.framlib.baseadapter.lv.LvCommonAdapter;
import com.byt.framlib.baseadapter.lv.LvViewHolder;
import com.byt.framlib.commonwidget.NoScrollListview;
import com.byt.framlib.commonwidget.StatusBarUtil;
import com.byt.framlib.commonwidget.onclicktwo.AntiShake;
import com.byt.framlib.commonwidget.refresh.RefreshHeaderView;
import com.lzm.ydpt.R;
import com.lzm.ydpt.entity.mall.CurrencyRecord;
import com.lzm.ydpt.mvp.contract.MyVCurrencyContract;
import com.lzm.ydpt.mvp.presenterimpl.MyVCurrencyPresenterImpl;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;

import java.util.ArrayList;
import java.util.List;

import androidx.annotation.NonNull;
import butterknife.BindView;
import butterknife.OnClick;

/**
 * 我的综苞粒页面
 */
public class MyVCurrencyActivity extends BaseActivity<MyVCurrencyPresenterImpl> implements MyVCurrencyContract.View {
    @BindView(R.id.tv_my_currency)
    TextView tv_my_currency;
    @BindView(R.id.srf_my_currency)
    SmartRefreshLayout srf_my_currency;
    @BindView(R.id.rv_my_currency)
    NoScrollListview rv_my_currency;
    private List<CurrencyRecord> list = new ArrayList<>();
    private LvCommonAdapter<CurrencyRecord> adapter = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        isShow = false;
        super.onCreate(savedInstanceState);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_my_vcurrency;
    }

    @Override
    public MyVCurrencyPresenterImpl initPreData() {
        return new MyVCurrencyPresenterImpl(this);
    }

    @Override
    public void initView() {
        initRefrsh();
        initAdapter();
    }

    private void initRefrsh() {
        setRefreshLayout(srf_my_currency);
        srf_my_currency.setEnableRefresh(true);
        srf_my_currency.setEnableLoadMore(false);
        srf_my_currency.setRefreshHeader(new RefreshHeaderView(mBContext).getHeaderStyleStaffMain());
        srf_my_currency.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
            @Override
            public void onLoadMore(@NonNull RefreshLayout refreshLayout) {

            }

            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {

            }
        });
    }

    private void initAdapter() {
        list.add(new CurrencyRecord());
        list.add(new CurrencyRecord());
        list.add(new CurrencyRecord());
        list.add(new CurrencyRecord());
        list.add(new CurrencyRecord());
        list.add(new CurrencyRecord());
        list.add(new CurrencyRecord());
        adapter = new LvCommonAdapter<CurrencyRecord>(mBContext, list, R.layout.item_my_currency_record_lv) {
            @Override
            protected void convert(LvViewHolder holder, CurrencyRecord shopInfoBean, int position) {
//                holder.setText(R.id.tv_currency_record_title, "");
//                holder.setText(R.id.tv_currency_state_num, "");
//                holder.setTextColor(R.id.tv_currency_state_num, Color.parseColor("#FFA800"));
//                holder.setTextColor(R.id.tv_currency_state_num, Color.parseColor("#333333"));
//                holder.setText(R.id.tv_currency_state_all, "");
//                holder.setText(R.id.tv_currency_record_time, "");
            }
        };
        rv_my_currency.setAdapter(adapter);
    }


    @OnClick({R.id.img_my_currency_back, R.id.tv_my_currency})
    public void onClick(View view) {
        if (AntiShake.check(view.getId())) {
            return;
        }
        switch (view.getId()) {
            case R.id.img_my_currency_back:
                finish();
                break;
            case R.id.tv_my_currency:
                openActivity(MallMainActivity.class);
                break;
        }
    }

    @Override
    protected void setStatusBar() {
        StatusBarUtil.setTranslucentForImageViewInFragment(this, null);
    }

    @Override
    public void onMyVCurrency() {

    }

    @Override
    public void showMessage(String message, String method) {

    }

    @Override
    public void showErrorView(String msg) {

    }
}
